#include "bullet.h"
#include<QPixmap>
#include<QRect>
Bullet::Bullet() {
    //加载资源
    m_Bullet.load(":/PVZ/images/Pea.png");
    m_x = 250;//-m_Bullet.width()*0.5;
    m_y = 100;
    //子弹状态 默认空闲
    m_free = true;
    //子弹速度
    m_Speed = 20;
    //子弹边框
    m_Rect.setHeight(10);
    m_Rect.setWidth(10);
    m_Rect.moveTo(m_x, m_y);

}
void Bullet::updatePosition() {
    //空闲状态的子弹不需要计算坐标
    if (m_free) {
        return;
    }
    //子弹向右移动
    m_x += m_Speed;
    m_Rect.moveTo(m_x, m_y);
    if (m_x >= 900) {
        m_free = true;
    }
}
